1. Field of the Invention
The present invention relates to a method, system, and program for generating statements while processing a program in a debugging mode to determine the execution path of the program.
2. Description of the Related Art
As part of the software development process, software developers must test and debug their programs. One technique for debugging a program is to intersperse coded statements, referred to as tracing statements, within the software. When the program is executed, the trace statements are generated as output. The software developer can then determine the paths of execution of the program by reviewing the trace statements that were outputted during execution. Some tracing methods operate by having a separate debugging program that monitors the operation of the target program, i.e., the program including the trace statements that is being debugged. This debugging program would be called each time a trace statement is referenced in the target program. However, such techniques can substantially degrade the performance of executing the target program as the debugging program interrupts the execution of the target program.
Although tracing methods for debugging programs are well known in the art, and described in U.S. Pat. No. 5,067,073, entitled xe2x80x9cEmbedded Tracing Method for Identifying Program Executed Paths,xe2x80x9d there is no specific tracing program for the Java computer language. Thus, there is a need in the art to provide efficient tracing programs for use in debugging Java programs, such as Java applets.
To overcome the limitations in the prior art described above, preferred embodiments disclose a system, method, and program for generating trace statements to a log file. A log method in a program including an identifier parameter is processed. The program includes multiple instances of the log method to trace the execution of the program during debugging operations. A determination is made as to whether a variable indicates that log methods called with the identifier parameter should be processed. The class and method from which the log method was called is determined if the variable indicates that log methods called with the identifier parameter should be processed. Information on the identifier parameter and determined class and method are written to the log file.
In further embodiments, the log method is processed by a thread executing the program. This thread determines whether the variable indicates that the processed log method should be processed and the class and method from which the log method was called.
Still further, the thread executing the program is executing in a first process. The thread calls a second process separate from the first process. This second process writes the trace statements to a buffer and periodically writes the trace statements from the buffer to the log file.
Yet further, the first process in which the program is executing is capable of simultaneously processing multiple log methods called from multiple threads executing in the first process. Each thread executing in the first process is capable of separately determining the class and method for each of the multiple log methods that are processed.
Preferred embodiments provide a technique for generating a trace log file for programs, such as Java programs, that simplify what is required of the software developer. With preferred embodiments, the software developer need only insert methods with a few parameters at different points within the program to monitor the path of execution of the program. Further, because in preferred embodiments a daemon in a separate process is writing the log statements to the log file, the operations of the logger daemon do not affect the execution of the program. For this reason, any failure or interruption in the execution of the program will not interfere with the logging operations of the separate logger daemon process.
Preferred embodiments are particularly suited for programming languages, such as Java, that do not include simplified tools for logging statements when debugging a program.